home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_1
/
hamgeo_c
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
19KB
From: Charles Patton <charliep@hpcvrs.cv.hp.com>
Subject: v03i045: hamgeo_cp - Hamilton Geodesy v1.0, Part01/01
Newsgroups: comp.sources.hp48
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu
Checksum: 566192616 (verify with brik -cv)
Submitted-by: Charles Patton <charliep@hpcvrs.cv.hp.com>
Posting-number: Volume 3, Issue 45
Archive-name: hamgeo_cp/part01
BEGIN_DOC HamiltonGeodesy.doc
@ Version 1.0 @
_Introduction_
The programs contained in this document comprise a collection
of simple-minded utilities for use in computing approximate orbits
of Hamiltonian dynamical systems in three space variables.
These utilites are the outcome of messing around with ways of
computing geodesics on implicitly-defined surfaces embedded in Euclidean
space. There is nothing new about the method involved, rather, the nicest
thing is how easy it is to "follow your nose" when working in an
environment like that of the '48.
All suggestions, additions, corrections, insights, commentary,
and criticisms are welcome.
_NO WARRANTY_
This work is provided on an "as is" basis. Hewlett-Packard Co.
provides no warranty whatsoever, either express or implied regarding
the work, including warranties with respect to its merchantability or
fitness for any purpose whatsoever.
_Copyright_
Copyright (C), 1991, Hewlett-Packard Co. Permission to copy all or
part of this work is granted provided that the copies are not made or
distributed for resale (excepting nominal copying fees) and the
_NO WARRANTY_ and this copyright notice are included verbatim. Other
permissions can be arranged by contacting the author.
_Correspondence_
Correspondence on HamiltonGeodesy should be sent to Charles Patton
at one of the following addresses:
snail-mail:
M.S. 5U-L9
Hewlett-Packard Co.
1000 N.E. Circle Blvd.
Corvallis, OR 97330
e-mail:
charliep@cv.hp.com (for Internet hosts)
hplabs!hpcvrs!charliep (for UUCP hosts)
_Overview_
Recall that the Hamilton-Jacobi formulation of classical mechanics
starts with the energy function ("Hamiltonian") as a function of position
and momentum of the system in question: q,p --> H(q,p). The Hamilton
equations then say that the time derivative of the position is the
derivative of H with respect to momentum, and the time derivative of
the momentum is the negative of the derivative of H with respect to
the position: q'=dH/dp ; p'=-dH/dq. The orbits of the Hamiltonian are
the integral curves of this system of differential equations, that is,
curves q(t),p(t) which satisfy dq/dt=dH/dp and dp/dt=-dH/dq.
Perhaps the simplest way to formulate the problem of finding
geodesics on a Riemannian space is as a Hamiltonian system. In this case,
the Hamiltonian is just the function which assigns to a position and
momentum half the squared length (according to the local metric) of the
momentum:
H(q,p)=0.5 Sum g (q) p p
i,j ij i j
where g(q) is the metric at q. In this case, the projection onto
position space of the orbits of the Hamiltonian are the geodesics.
If we are trying to find geodesics on a surface emdedded in
Euclidean space, we could find local coordinates for the surface,
compute the metric in local coordinates, and then use the above
formulation to find geodesics in terms of these local coordinates.
This is almost always difficult to do.
We will take a different approach here, the key difference being
that we are assuming that the surface is given to us as the zero-set
of a function F: q --> F(q) defined on the Euclidean space. We can use
F to define a potential function on the Euclidean space with a minimum
along the desired surface and use the Euclidean metric together to define
the Hamiltonian:
2 2 2
H(q,p)=k F(q) +0.5 ||p||
for some "large" constant, k.
If we start with any initial q,p with F(q)=0 and p "tangent" to
the the surface, the projection onto position space of the resulting
orbit will approximate a geodesic on the desired surface. You can
think of this as describing a particle attached to the surface by a
sliding, frictionless spring. If the spring is very stiff, the
particle will follow the path of a geodesic when it is given a shove
along the surface. If the spring is not so stiff, the particle will
combine near-geodesic motion with oscillations normal to the surface.
_Organization and Descriptions of the Programs_
The utilities are arranged in a directory with the two top-level
programs first, and the supporting utilities and variables afterwords.
The space coordinates are represented by the variables, 'x' 'y' and 'z'
(note the lower case.) The corresponding momentum coordinates are 'px'
'py' and 'pz'.
SetUpHamiltonian:
Given the function kF, on the stack, as an expression in the space
variables, 'x' 'y' and 'z', this program creates the Hamiltonian
described above and stores it in the variable 'H' for future
reference. It then computes the components, 'xdot'...'pzdot',
corresponding to the Hamiltonian equations. It then calls on the
utility Lie4thOrder to compute a (formal) fourth order polynomial
approximation to the solution of the system of Hamilton equations,
storing the formulae for the increments as '<delta>x'...'<delta>pz'.
This takes a loooong time so go out for a coffee break after firing it
up.
After this finishes, you are ready to plot approximate geodesics on your
surface.
You can easily customize this program to set up for an arbitrary
Hamiltonian in these variables by deleting the first line of the
program listed, below, and storing your choice of Hamiltonian (as an
expression in 'x'...'pz') in the variable 'H' before running
SetUpHamiltonian.
N.B.>Insure that 'x' 'y' 'z' 'px' 'py' and 'pz' are formal (no variables
N.B.>with those names along the current path.)
N.B.> Examine the MODES menu to be sure that the
N.B.> the machine is in SYMBOLIC EVALUATION mode ( SYM button.)
RunHamiltonian:
This program takes initial values for x y z px py and pz on the
stack and computes successive points (approximately) on the orbit of
the Hamiltonian. It graphs these by lines connecting successive (x,z)
pairs (i.e. projection of the orbit on the x-z plane) using the
current PPAR values for the horizontal and vertical scaling of the
screen. It requires that you have previously run SetUpHamiltonian in
the current directory.
As part of its initialization, it takes the current value of the
stepsize (stored in the variable <delta>) and pre-computes the higher
order stepsizes (<delta>^2/2, <delta>^3/6, and <delta>^4/24) storing
these in <delta>2 <delta>3 and <delta>4. As explained below, the
default value of <delta> is 0.1, but you can use any value you wish as
long as you store it before running this program.
You should exit this program by pressing the [ENTER] key. When
this is done, the program will clean up and leave the last computed
values of x...pz on the stack ready for continuation of the orbit, if
desired.
HamiltonStep:
This simple utility takes the values off the stack, stores them
in 'x'...'pz', computes the next step and returns the values to the
stack.
Lie4thOrder:
This routine constitutes the heart of this collection of
utilities. The idea is that applying the Lie derivative operator
d d d d d d
L:=x'- + y'- + z'- + px'- + py'- + pz'-
dx dy dz dpx dpy dpz
to any function, f, corresponds to taking the time derivative of f
along the orbits of the Hamiltonian. Thus, the fourth-order Taylor
series approximation to the time evolution of f is
f+(Lf)t+(LLf)t^2/2+(LLLf)t^3/6+(LLLLf)t^4/24
Using this on each of the coordinate functions, x...pz, thus gives
an approximation to the orbits themselves. This program computes this
approximation for each of the coordinate functions using <delta> as
the time-step, t. This is equivalent (in the limit of small time-step)
to the fourth-order Runge-Kutte method of approximating solutions to
ordinary differential equations, but has the advantage of being much
more comprehensible. It also allows you to compute the approximate
time evolution of any smooth function, not just the coordinate
functions, in exactly the same manner.
The resulting approximation is subject to the same kinds of
instabilities as the R-K method. In our case, this shows up when the
approximation overshoots into a region where the added potential is
steep. This causes the next step to overshoot even more in the other
direction, quickly leading to huge values for the position and
momentum coordinates. For this reason, you should leave <delta> at its
default value, and if instabilites become apparent, choose a smaller
value for the initial velocity. The point here being that while the
space-projection of the orbits of the geodesic equation don't depend
on the initial velocity, the orbits of our approximation do. They are
only asymptotic to the geodesics in the limit of small initial
velocity. Moreover, no choice of potential will fix that. You can
think of it like a motorcycle driving in a groove. At low velocity, it
will follow the groove nicely, but at high velocity, it will "bank"
its turns on the wall of the groove, hence the possibility for
overshoot becomes more serious.
LieDer:
This utility takes a function, given as an expression in x...pz,
and computes its Lie derivative according to the current values of
'xdot'...'pzdot' which correspond to x'...pz'.
The Other Variables:
<delta>...<delta>4 and 'H' were explained previously. The others
are placeholders for values computed during the operations of the
main programs.
Using the Programs:
To download this to a '48, you can either type in the listings
given below, making the translation from the backslash form of the
characters to the corresponding '48 characters, or strip off
everything prior to and including "BEGIN_RPL HamiltonGeodesy" below,
and the final line "END_RPL" and then download the resulting file in
ASCII mode to your '48. The result in either case will be a directory
containing the programs and variables described above.
END_DOC
BEGIN_RPL HamiltonGeodesy.rpl
%%HP: T(3)A(R)F(.);
DIR
SetUpHamiltonian
\<< 2 ^ '0.5*(px^2+py^2+pz^2)' + 'H' STO
H 'x' \.d COLCT NEG 'pxdot' STO
H 'y' \.d COLCT NEG 'pydot' STO
H 'z' \.d COLCT NEG 'pzdot' STO
H 'px' \.d COLCT 'xdot' STO
H 'py' \.d COLCT 'ydot' STO
H 'pz' \.d COLCT 'zdot' STO
'x' Lie4thOrder '\Gdx' STO
'y' Lie4thOrder '\Gdy' STO
'z' Lie4thOrder '\Gdz' STO
'px' Lie4thOrder '\Gdpx' STO
'py' Lie4thOrder '\Gdpy' STO
'pz' Lie4thOrder '\Gdpz' STO
\>>
RunHamiltonian
\<< 6 PICK 5 PICK R\->C
\-> U
\<< \Gd \Gd * 2 / DUP '\Gd2' STO
\Gd * 3 / DUP '\Gd3' STO
\Gd * 4 / '\Gd4' STO
{ # 0d # 0d } PVIEW
DO
HamiltonStep
6 PICK 5 PICK R\->C
DUP U LINE 'U' STO
UNTIL KEY
END DROP {x y z px py pz} PURGE
\>>
\>>
HamiltonStep
\<< 'pz' STO 'py' STO 'px' STO
'z' STO 'y' STO 'x' STO
\Gdx \->NUM x +
\Gdy \->NUM y +
\Gdz \->NUM z +
\Gdpx \->NUM px +
\Gdpy \->NUM py +
\Gdpz \->NUM pz +
\>>
Lie4thOrder
\<< LieDer COLCT DUP '\Gd' *
SWAP LieDer COLCT DUP '\Gd2' *
ROT SWAP + SWAP
LieDer COLCT DUP '\Gd3' * ROT SWAP
+ SWAP LieDer COLCT '\Gd4' * +
\>>
LieDer
\<< \-> N
\<< N 'x' \.d xdot *
N 'y' \.d ydot * +
N 'z' \.d zdot * +
N 'px' \.d pxdot * +
N 'py' \.d pydot * +
N 'pz' \.d pzdot * +
\>>
\>>
H 'px^2+py^2+pz^2+(x^2+y^2-z)^2'
PPAR {(-6.5,-3.1) (6.5,3.2) X 0 (0,0) FUNCTION Y }
xdot 0
ydot 0
zdot 0
pxdot 0
pydot 0
pzdot 0
\Gdx 0
\Gdy 0
\Gdz 0
\Gdpx 0
\Gdpy 0
\Gdpz 0
\Gd .1
\Gd2 .005
\Gd3 1.66666666667E-4
\Gd4 4.16666666668E-6
END
END_RPL
BEGIN_ASC HamiltonGeodesy.asc
%%HP: T(3)A(D)F(.);
"69A20FF7E1A000000020294320339204998666666666140D1000202933203392
06997666666666610D100020292320339207990000000000050D100010291033
9209990000000000010B1000302907A730339200000000000000000F10003029
079730339200000000000000000F10003029078730339200000000000000000F
10002029A720339200000000000000000D100020299720339200000000000000
000D100020298720339200000000000000000D10005007A746F6475033920000
00000000000003200050079746F6475033920000000000000000032000500787
46F647503392000000000000000003200040A746F64740339200000000000000
00012000409746F6474033920000000000000000012000408746F64740339200
0000000000000001200040050514254047A20779200000000000000569000000
0000000139779200000000000000560000000000000023084E2010854B2A2779
2000000000000000000000000000000000166E184E201095B21301A000108410
8BA2084E20200787ED2A2D20B184E20200797ED2A2D20B176BA184E202007A7E
D2A2D20B176BA184E201087ED2A2D20B184E201097ED2A2D20B176BA184E2010
A790DA1ED2A2D20B176BA1B21301A00060C4965644562760D9D20E16321C432D
6E2010E4E1632D6E2010E44563284E20108797632E7FE184E20408746F647EED
A1D6E2010E44563284E20109797632E7FE184E20409746F647EEDA176BA1D6E2
010E44563284E2010A797632E7FE184E2040A746F647EEDA176BA1D6E2010E44
563284E2020078797632E7FE184E2050078746F647EEDA176BA1D6E2010E4456
3284E2020079797632E7FE184E2050079746F647EEDA176BA1D6E2010E445632
84E202007A797632E7FE184E205007A746F647EEDA176BA1EF53293632B2130F
9100B0C49656434786F427465627B0D9D20E163284E2060C4965644562751A02
78BF14563284E20102997632EEDA1DBBF184E2060C4965644562751A0278BF14
563284E2020292397632EEDA1E0CF1DBBF176BA1DBBF184E2060C49656445627
51A0278BF14563284E2020293397632EEDA1E0CF1DBBF176BA1DBBF184E2060C
4965644562751A024563284E2020294397632EEDA176BA193632B213053100C0
8416D696C647F6E635475607C0D9D20E16324563284E202007A797632DCC0245
63284E2020079797632DCC024563284E2020078797632DCC024563284E2010A7
97632DCC024563284E20109797632DCC024563284E20108797632DCC0284E202
029874E5A184E20108776BA184E202029974E5A184E20109776BA184E202029A
74E5A184E2010A776BA184E20302907874E5A184E2020078776BA184E2030290
7974E5A184E2020079776BA184E20302907A74E5A184E202007A776BA193632B
213068100E02557E68416D696C647F6E69616E6E0D9D20E1632233A2A9CF1D13
A2A9CF1E97C11C432D6E201055E163284E20102984E201029EEDA1ED2A250FA1
78BF14563284E2020292397632DCC0284E201029EEDA13F2A250FA178BF14563
284E2020293397632DCC0284E201029EEDA1803A250FA14563284E2020294397
632DCC0247A20E4A20510000000000000000000E4A2051000000000000000000
0B21300F2E13C03284E20C08416D696C647F6E635475607233A2A9CF1D13A2A9
CF1E97C178BF1D6E201055893E145632D6E20105597632DCC02DE032378A19B6
328DBF147A2084E20108784E20109784E2010A784E2020078784E2020079784E
202007A7B2130EFE02EF53293632B2130812000135564755078416D696C647F6
E69616E601D9D20E1632ED2A2D20B18BA2033920999000000000005084E20200
787ED2A2D20B184E20200797ED2A2D20B176BA184E202007A7ED2A2D20B176BA
1EEDA1B213076BA14563284E20108497632DCC0284E2010844563284E2010879
7632E7FE151A02599A14563284E2050078746F64797632DCC0284E2010844563
284E20109797632E7FE151A02599A14563284E2050079746F64797632DCC0284
E2010844563284E2010A797632E7FE151A02599A14563284E205007A746F6479
7632DCC0284E2010844563284E2020078797632E7FE151A024563284E2040874
6F64797632DCC0284E2010844563284E2020079797632E7FE151A024563284E2
0409746F64797632DCC0284E2010844563284E202007A797632E7FE151A02456
3284E2040A746F64797632DCC024563284E2010879763284E20B0C4965643478
6F4274656274563284E2020298797632DCC024563284E2010979763284E20B0C
49656434786F4274656274563284E2020299797632DCC024563284E2010A7976
3284E20B0C49656434786F4274656274563284E202029A797632DCC024563284
E202007879763284E20B0C49656434786F4274656274563284E2030290787976
32DCC024563284E202007979763284E20B0C49656434786F4274656274563284
E203029079797632DCC024563284E202007A79763284E20B0C49656434786F42
74656274563284E20302907A797632DCC0293632B2130CE7E"
END_ASC
BYTES: #E7ECh 1866
BEGIN_UU HamiltonGeodesy.uue
begin 644 HamiltonGeodesy
M2%!(4#0X+466*O!_'@H````"DC0",RE`F6AF9F9F0=`!``*2,P(S*6"99V9F;
M9F86T`$``I(R`C,I<)D``````%#0`0`!D@$S*9"9```````0L`$``Y)P>@,SZ
M*0``````````\`$``Y)P>0,S*0``````````\`$``Y)P>`,S*0``````````\
M\`$``I)Z`C,I``````````#0`0`"DGD",RD``````````-`!``*2>`(S*0``9
M````````T`$`!7!Z9&]T!3,I```````````P`@`%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